<!doctype html><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<script src="https://cdn.bootcss.com/d3/3.5.17/d3.min.js"></script>
<title>d3比例尺</title>
</head>
<body>
    <script>
        var dataset_1 = [ 2.5 , 2.1 , 1.7 , 1.3 , 0.9 ];
        var dataset_2 = [ 2500, 2100, 1700, 1300, 900 ];
        var linear = d3.scale.linear().domain([d3.min(dataset_1), d3.max(dataset_1)]).range([d3.min(dataset_2), d3.max(dataset_2)]);
        console.log(linear(0.3));
        // domain 是作用域，range是值域
        var index = [0, 1, 2, 3, 4];
        var color = ["red", "blue", "green", "yellow", "black"];
        var ordinal = d3.scale.ordinal().domain(index).range(color);
        console.log(ordinal(2));
    </script>
</body>
</html>
